<script setup>
import { getOrderAPI } from '@/apis/pay'
import { onMounted, ref } from 'vue'
import { useRoute } from 'vue-router'
const route = useRoute()
const orderInfo = ref({})

const getOrderInfo = async () => {
  //const res = await getOrderAPI(route.query.orderId)
  //orderInfo.value = res.result
    const res = {
    "code": "1",
    "msg": "操作成功",
    "result": {
        "id": route.query.id || "1543591863523479553", // 使用实际的订单ID
        "createTime": "2022-07-03 21:45:53",
        "payType": 1,
        "orderState": 1, // 有效订单状态（1表示待支付）
        "payLatestTime": "2022-07-03 22:15:54",
        "countdown": 1712,
        "postFee": 6,
        "payMoney": 1139,
        "payChannel": 1,
        "payState": 0, // 未支付状态
        "totalMoney": 1133,
        "totalNum": 9,
        "deliveryTimeType": 1,
        "receiverContact": "张先生12",
        "receiverMobile": "15236363232",
        "provinceCode": "150000",
        "cityCode": "150600",
        "countyCode": "150625",
        "receiverAddress": "内蒙古自治区鄂尔多斯市杭锦旗仙霞西路885弄",
        "payTime": null,
        "consignTime": null,
        "endTime": null,
        "closeTime": null, // 订单未关闭
        "evaluationTime": null,
        "skus": [
            {
                "id": "1543591863607365633",
                "spuId": "3459033",
                "name": "软弹/保暖两款可选，女式舒软轻弹健步鞋",
                "quantity": 2,
                "image": "https://yanxuan-item.nosdn.127.net/1f95d579952f425d840dc051dafb6156.jpg",
                "realPay": 270,
                "curPrice": 135,
                "totalMoney": null,
                "properties": [
                    {
                        "propertyMainName": "颜色",
                        "propertyValueName": "灰色镂空"
                    },
                    {
                        "propertyMainName": "尺码",
                        "propertyValueName": "38"
                    }
                ],
                "attrsText": "颜色:灰色镂空 尺码:38 "
            }
        ],
        "arrivalEstimatedTime": null
    }
  }
  orderInfo.value = res.result
}

onMounted(() => getOrderInfo())

</script>


<template>
  <div class="xtx-pay-page">
    <div class="container">
      <!-- 支付结果 -->
      <div class="pay-result">
        <!-- 路由参数获取到的是字符串而不是布尔值 -->
        <span class="iconfont icon-queren2 green" v-if="$route.query.payResult === 'true'"></span>
        <span class="iconfont icon-shanchu red" v-else></span>
        <p class="tit">支付{{ $route.query.payResult === 'true' ? '成功' : '失败' }}</p>
        <p class="tip">我们将尽快为您发货，收货期间请保持手机畅通</p>
        <p>支付方式：<span>支付宝</span></p>
        <p>支付金额：<span>¥{{ orderInfo.payMoney?.toFixed(2) }}</span></p>
        <div class="btn">
          <el-button type="primary" style="margin-right:20px">查看订单</el-button>
          <el-button>进入首页</el-button>
        </div>
        <p class="alert">
          <span class="iconfont icon-tip"></span>
          温馨提示：理工商城不会以订单异常、系统升级为由要求您点击任何网址链接进行退款操作，保护资产、谨慎操作。
        </p>
      </div>
    </div>
  </div>
</template>

<style scoped lang="scss">
.pay-result {
  padding: 100px 0;
  background: #fff;
  text-align: center;
  margin-top: 20px;

  >.iconfont {
    font-size: 100px;
  }

  .green {
    color: #1dc779;
  }

  .red {
    color: $priceColor;
  }

  .tit {
    font-size: 24px;
  }

  .tip {
    color: #999;
  }

  p {
    line-height: 40px;
    font-size: 16px;
  }

  .btn {
    margin-top: 50px;
  }

  .alert {
    font-size: 12px;
    color: #999;
    margin-top: 50px;
  }
}
</style>